#!/usr/bin/env bash
cd /jenkins/web
cp rentapartment.jar /jenkins/release/rentapartment.jar
cd /jenkins/release


MYIMAGE=mydocker/rentapartment
imageid=`docker images|grep -i $MYIMAGE|awk '{print $3}'`

if docker ps -a|grep -i rentapartment;then
   docker rm -f rentapartment
fi

if [-z "$imageid" ];then
    echo "imageid is null"
else
    echo "imageid is" $imageid
    docker rmi -f $MYIMAGE
fi

docker build -t $MYIMAGE .

docker run  -d -p 8081:8081 --name rentapartment $MYIMAGE

